package com.caiyi.financial.nirvana.sms.controller;


import com.caiyi.financial.nirvana.sms.entity.SmsProduct;
import com.caiyi.financial.nirvana.sms.querybean.QueryProductBean;
import com.caiyi.financial.nirvana.sms.service.SmsProductService;
import com.youyu.common.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "产品管理")
@RestController
@CrossOrigin
@RequestMapping("sms/admin/product")
public class ProductController {

    @Autowired
    private SmsProductService productService;

    @ApiOperation(value = "添加Product详情", notes = "添加Product详情描述")
    @ApiImplicitParam(name = "smsProduct", value = "产品实体", required = true, dataType = "SmsProduct", paramType = "SmsProduct")
    @PostMapping("/addProduct")
    public Result addProduct(@RequestBody SmsProduct smsProduct) {
        return Result.ok(productService.addProduct(smsProduct));
    }

    @ApiOperation(value = "删除Product详情", notes = "删除Product")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/deleteProduct")
    public Result deleteProduct(Integer id) {
        return Result.ok(productService.deleteProduct(id));
    }

    @ApiOperation(value = "更新Product详情", notes = "更新Product")
    @ApiImplicitParam(name = "smsProduct", value = "产品实体", required = true, dataType = "SmsProduct", paramType = "SmsProduct")
    @PostMapping("/updateProduct")
    public Result updateProduct(@RequestBody SmsProduct smsProduct) {
        return Result.ok(productService.updateProduct(smsProduct));
    }


    @ApiOperation(value = "根据参数查找Product详情", notes = "根据参数查找Product详情描述")
    @PostMapping("/getProductByParams")
    @ApiImplicitParam(name = "bean", value = "查找产品参数", required = true, dataType = "QueryProductBean")
    public Result getProductByParams(@RequestBody QueryProductBean bean) {
        return Result.ok(productService.getProductByParams(bean));
    }

    @ApiOperation(value = "配置客户产品页面参数请求详情", notes = "配置用户产品页面参数请求详情描述")
    @PostMapping("/updateUserProductParams")
    public Result getUpdateUserProductParams() {
        return Result.ok(productService.getUpdateUserProductParams());
    }

    @ApiOperation(value = "配置用户产品详情", notes = "配置用户产品详情描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品id", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "account", value = "用户账号", dataType = "String", paramType = "query", required = true)})
    @PostMapping("/updateUserProduct")
    public Result updateUserProduct(Integer id, String account) {
        return Result.ok(productService.updateUserProduct(id, account));
    }


}
